草庐IT

Javascript JSON.stringify 函数不起作用

全部标签

javascript - 试图防止 jQueryMobile 滑动手势冒泡,但它不起作用

我正在使用jQueryMobile并创建了一些类似于AndroidHoloTabs的东西:http://note.io/18RNMRk为了让滑动手势能够在选项卡之间切换,这是我添加的代码:$("#myPage#pageTabs").on('swipeleftswiperight',function(e){e.stopPropagation();e.preventDefault();});$("#myPage").on('swipeleft',function(){ui.activities.swipe(1);}).on('swiperight',function(){ui.activi

javascript - 哪个 Javascript 函数放置更好?

我正在尝试构建一个游戏,我注意到对于组织来说,将一些函数放在其他函数中可能会更好,因为它们专门用于原始函数。例如:functionfn1(){fn2();functionfn2(){//Stuffhappenshere}}fn1被多次调用,fn1会在执行过程中多次调用fn2。当fn1被调用时,fn2是否每次都必须重新处理(因为缺少更好的词)?我是否因此而失去了性能?我应该像这样将fn2放在fn1之后吗?functionfn1(){fn2();}functionfn2(){//Stuffhappenshere} 最佳答案 你可以这样做

javascript - AngularJS 选择 ng-change 函数找不到选定的模型

我在处理一些基本的Angular数据绑定(bind)时遇到了问题。我的看法:AllPersons我的Controller:$scope.testdataset=[{name:"bill"},{name:"bob"},{name:"batman"}];$scope.personChanged=function(person){console.log(person);}效果很好——选择的名称已记录。Butthissimplyprints"undefined"whenanameisselected查看:AllPersonsController:$scope.testdataset=[{nam

javascript - TypeError : jQuery. easing[this.easing] 不是函数

这个问题在这里已经有了答案:TypeError:p.easing[this.easing]isnotafunction(12个答案)关闭6年前。我需要为我的jQuery链接添加一个效果,但它只适用于最低1.7.1,而我有另一个代码只适用于1.10.2。此代码仅适用于1.10.2$(document).ready(function(){varmenu=document.querySelector('#menu-bar-wrapper');varorigOffsetY=menu.offsetTop;functionscroll(){if($(window).scrollTop()>=ori

用于多边形 bool 函数(并、交、差和异或)的 javascript 模块

关闭。这个问题不符合StackOverflowguidelines.它目前不接受答案。我们不允许提出有关书籍、工具、软件库等建议的问题。您可以编辑问题,以便可以用事实和引用来回答它。去年关闭。Improvethisquestion我有多边形集。在这个集合中,有些是外部多边形,有些可能(或可能不是)是孔。在这个阶段我不知道哪些是多边形孔。我想计算结合所有多边形(包括孔)的最终多边形。我想到了这种方法://'SomeLib'thathaspolygonbooleanfucntionsvarpolygonSet=[poly1,poly2,...polyn];varunion,intersec

javascript - json 数据上的 Angular js 中的 Slick Carousel 不起作用

我使用这个程序github.com/vasyabigi/angular-slick.它不适用于动态数据。它只适用于静态数据。在动态数据中,它显示垂直图像而不是水平图像,没有轮播。请帮助我。这是我的指令directive('slick',function($timeout){return{restrict:"AEC",scope:{initOnload:"@",data:"=",currentIndex:"=",accessibility:"@",arrows:"@",autoplay:"@",autoplaySpeed:"@",centerMode:"@",centerPadding:

javascript - typescript 覆盖构造函数中的扩展属性

我在使用Typescript时遇到问题,我扩展了一个类并从父类(superclass)覆盖了一个属性,但是当我实例化子类时,父类(superclass)属性仍然在构造函数中读取。请看下面的例子:classPerson{publictype:string='GenericPerson';publicconstructor(){console.log(this.type);}}classClownextendsPerson{publictype:string='ScaryClown';}varperson=newPerson(),//'GenericPerson'clown=newClow

javascript - 从文件目录结构创建 JSON 数据的高效函数?

如标题所说,我有一个目录结构,我想将它转换成兼容jsTreeusage的JSON格式.所以给定列表的输出输入:./SimpleRootNode./RootNode2./RootNode2/Child1./RootNode2/Child2输出:treeJSON=[{"id":"ajson1","parent":"#","text":"Simplerootnode"},{"id":"ajson2","parent":"#","text":"Rootnode2"},{"id":"ajson3","parent":"ajson2","text":"Child1"},{"id":"ajson4"

javascript - 如果不查询宽度属性,过渡就不起作用

我想通过向js中的div添加一个类来为点击事件上的translateX设置动画。transform和transition属性添加到css文件中。varwidget=document.getElementById('widget');widget.style.display='block';document.getElementById('widget2').clientWidth;//commentthislineoutanditwontworkwidget.className='visible';只有当我在添加类之前查询dom中任何元素的宽度属性时,它才有效。这是一个jsfiddle

javascript - 测试未导出的 TypeScript 函数

我使用Mocha/Chai测试JavaScript前端代码,现在我们切换到TypeScript。我有几个要测试的功能。但它们不应该是可导出的。我可以在不向它们添加export的情况下访问此函数并对其进行测试吗? 最佳答案 无法访问未导出的模块函数。moduleMyModule{functionprivateFunction(){alert("privateFunction");}}MyModule.privateFunction();//Generatesacompilererror但是,撇开私有(private)​​方法测试的有效